#include"Progress.h"
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#define NUM 101
#define STYLE '='



//version2
void Process(double current, double total)
{
    const char *lable = "|/-\\";
    char bar[(int)current];
    double rate = (current/total)*100;
    memset(bar, '\0', sizeof(bar));
   for(int i = 0; i < (int)rate; i++)
   {
       bar[i] = STYLE;
   }
    printf("[%-100s][%lf%%][%c]",bar, total, lable[(int)total%4]);

    fflush(stdout);

    usleep(100000);
}



//version1
//void Process() {
//    const char *lable = "|/-\\"; 
//    char bar[NUM];
//    memset(bar, '\0',sizeof(bar));//字符串原始设为空
//    int count = 0;
//    while(count <= 100)
//    {
//        printf("[%-100s][%d%%][%c]\r",bar,count,lable[count%4]);
//        fflush(stdout);
//        bar[count] = STYLE;
//        usleep(100000);
//        count++;
//    }
//    printf("\r\n");
//}
